package com.jkl.controller.bsWorkflow;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jkl.entity.BaseResponseDTO;
import com.jkl.entity.bsWorkflow.BsWorkflow;
import com.jkl.service.bsWorkflow.inter.BsWorkflowServiceInterface;

import lombok.extern.slf4j.Slf4j;

@RestController
@RequestMapping("/jky/bsWorkflow")
@Slf4j
public class BsWorkflowController {

	@Autowired
	private HttpServletRequest request;

	@Autowired
	private BsWorkflowServiceInterface bsWorkflowServiceInterface;

	@PostMapping("/getWorkflowList")
	public List<BsWorkflow> getWorkflowList() {
		return bsWorkflowServiceInterface.getWorkflowList();
	}

	@PostMapping("/getBsWorkflowList")
	public BaseResponseDTO getIndexList(@RequestBody BsWorkflow bsWorkflow) {
		BaseResponseDTO returnData = new BaseResponseDTO();

		List<BsWorkflow> bsWorkflowList = bsWorkflowServiceInterface.parentNodeCode(bsWorkflow);
		JSONObject returnJson = new JSONObject();
		JSONArray bsWorkflowArray = (JSONArray) JSONArray.toJSON(bsWorkflowList);
		returnJson.put("drIndexList", bsWorkflowArray);
		returnData.setReturnData(returnJson);
		return returnData;

	}

}
